package com.leoman.spinningmachine.util;

import com.leoman.spinningmachine.constant.Constant;
import com.leoman.spinningmachine.http.APIResponse;

import cn.bingoogolapple.refreshlayout.BGARefreshLayout;

/**
 * Created by Administrator on 2018-06-07.
 */

public class BGARefreshUtil {
    public static int REFRESH = 10001;
    public static int LOADMORE = 10002;

    //tag =1 下拉刷新  2 上拉加载更多
    public static void endLoading(int tag, BGARefreshLayout bgaRefreshLayout){
        if(tag == 1){
            endRefreshing(bgaRefreshLayout);
        }else if(tag == 2){
            DialogUtils.getInstance().cancel();
            endLoadingMore(bgaRefreshLayout);
        }
    }

    public static void endRefreshing(BGARefreshLayout bgaRefreshLayout){
        if(bgaRefreshLayout!=null){
            bgaRefreshLayout.endRefreshing();
        }
    }
    public static void endLoadingMore(BGARefreshLayout bgaRefreshLayout){
        if(bgaRefreshLayout!=null){
            bgaRefreshLayout.endLoadingMore();
        }
    }

    //是否是最后一页
    public static boolean getIsLastPage(APIResponse apiResponse) {
        if(apiResponse.data.list!=null&&apiResponse.data.list.size()< Constant.pageSize){
            return true;
        }else{
            return false;
        }
    }
}
